<?php

namespace app\admin\controller\business;

use app\common\controller\Backend;

class OrderProject extends Backend
{
    /**
     * Notes: 项目收入单
     * User: AerYYY
     * Date: 2/6/24 9:25 PM
     * @return string
     * @throws \think\Exception
     * @throws \think\exception\PDOException
     */
    public function income()
    {
        if ($this->request->isPost()) {
            $params = $this->request->post();
            $params['admin_id'] = $this->auth->id;

            $orderProjectModel = new \app\admin\model\business\OrderProject();
            $orderProjectModel->startTrans();
            if ($orderProjectModel->income($params)) {
                $orderProjectModel->commit();
                $this->success('ok');
            }
            $orderProjectModel->rollback();
            $this->error($orderProjectModel->getError());
        }

        $order_no = order_no('SR');
        $this->assign('order_no', $order_no);
        return $this->view->fetch();
    }

    public function expenditure()
    {

        if ($this->request->isPost()) {
            $params = $this->request->post();
            $params['admin_id'] = $this->auth->id;

            $orderProjectModel = new \app\admin\model\business\OrderProject();
            $orderProjectModel->startTrans();
            if ($orderProjectModel->expenditure($params)) {
                $orderProjectModel->commit();
                $this->success('ok');
            }
            $orderProjectModel->rollback();
            $this->error($orderProjectModel->getError());
        }

        $order_no = order_no('ZC');
        $this->assign('order_no', $order_no);
        return $this->view->fetch();
    }
}